<template>
  <div>
    <el-form :inline="true" :model="formInline" class="demo-form-inline">
      <el-form-item label="用户名">
        <el-input v-model="formInline.name" placeholder="用户名"></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input v-model="formInline.pwd" placeholder="密码"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="login">登录</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: "LoginView",
  data() {
    return {
      formInline:{},
    }
  }, methods: {
    login(){
      this.axios.post("login",this.formInline).then(res=>{
        if (res.data.code==200){
          sessionStorage.setItem("token",res.data.data.token);

          this.$message.success(res.data.msg);
          this.$router.push("/add");
        }else{
          this.$message.error(res.data.msg);
        }
      })
    }
  }, created() {

  }
}
</script>

<style scoped>

</style>